home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 8
/
Amoszine 8 (Disk 2 of 3).adf
/
AMON_Extension.lha
/
amon_extension
/
Amon1.3.doc
next >
Wrap
Text File
|
1995-08-07
|
18KB
|
610 lines
*************************
THE A M O N Extension
*************************
A FryUp Productions Product For AmosPro
=======================================
Version 1.03
By
Paul Overy 7/8/1995 (last update)
Install Notes:
--------------
- Run the Interpreter/config program.
- Load the default config & then enter the loaded extensions.
- Enter the name of the new extension in slot 15.
Type "AmosPro_Amon.lib".
- Save the new configuration.
- Use Workbench/AmigaDos to Copy the "AmosPro_Amon.lib" library into the APSystem draw.
- Also copy the "Amon_Bank.10" to the same draw. (only needed for fast angle)
Some examples can also be found on the disk.
Why More Mouse/keyboard Commands?
---------------------------------
Amos can be sped up by throwing out the multitasking system. Lets face it,
how often do you make use of the multitasking system when playing a game?
However this does have one bad side effect in that, mouse control is lost.
In fact all Amos mouse/keyboard commands because useless.
Amos Classic gives a greater speed up with multi off, as AmosPro still lets
mouse/keyboard codes trickle through and these are not really frequent enough to use.
How do I turn off the multitasking system?
MAKE USE of these two lines:-
========
Break Off : NUL=Execall(-132) :Rem Multitasking Off
NUL=Execall(-138) : Break On :Rem Multitasking On
Place multi Off at start of your code & Multi On at end of your code.
Its also a good idea to use "Amos Lock" before multi off. Then Ctrl-c will
have no effect, so you can't break the program editor with multitasking off.
WARNING:
If your program throws up an error, with multitasking still off, you MUST go into
direct mode straight away, and turn it back on with nul=execall(-138).
Its really best to code with those two lines commented out, and include
them once you have finished.
COPYRIGHT © NOTES:
-----------------
This package is SHAREWARE. It's the full version so far with no pop up messages.
* No charge is required if Amon is used under the editors interpretor.
* A charge of £5 is required when using the extension in independent compiled code.
For this you will receive the very latest version, plus free future support.
Price includes disk & postage costs for your latest version, and 2 pints for me
down the pub. This fee can be paid in UK postage stamps, hard cash or a
cheque in my name.
Anyone outside the UK will have to add any extra postage cost, and find a fit
method of payment that does not lose out too badly in exchange rates.
(Future updates after that will required a S.A.E + disk)
If anyone wants slot number 15 changed, just ask.
My Name & address,
PAUL OVERY
27 Barton Road
Maidstone
Kent
ME15 7BU
ENGLAND.
*** All thoughts & ideas are welcome ***
DISCLAIMER
----------
I cannot be held responsible for any damage to you, your computing equipment, your
programs, or any data as result of use the Amon extension, either directly or
consequentially as a result of its use.
By using the Amon extension you agree to these terms and agree not to hold me
liable for any damages arising from use of this package. Use the Amos extension
package at your own risk.
HISTORY
-------
V1.00 - Private version.
V1.01 - First public version, released as Shareware.
- 17/7/95
- New command added, Set Angle Bank.
- Fixed small bug in Fast Angle.
Now reports top angles OK.
- Fix negative sin/cos values, now returned in longword format.
Plotting these values worked fine, later the print command did however
reveal the problem. It seems that the plot command reads its coordinates
word size, this error had me puzzled for some time. (Bed time 1.45am)
- 18/7/95
- "Amon_bank.10" was 35k, now only 2.44k. Fast Angle routine now handles
better scaling.
- Added User scaling to Fast Angle Routine.
Syntax now: =Fast Angle(X1,Y1 to X2,Y2,SCALE)
- Recalculated Table & updated angle routine to make better use of whole
bytes. Angle resolution is now very much better. (Bed time 3.00am)
- 19/7/95
- Placed "Amon_bank.10" table in extension code.
- Removed the Set Angle Bank command.
- Added more safe guards & error messages. (PUB TIME)
- 20/7/95 (back from pub)
- SinCos table data now shared, saved 182 bytes (every little bit helps).
- Bed time (1.32am)
V1.02 - 23/7/95
- New command added, Rodent Key.
- New comandd added, Set Rodent.
- Added option to leave out x1,y1 paramaters from Fast Angle
Now it can also use current rodent x/y values instead.
V1.03 - 6/8/95
- Code optimised in places.
- Fixed bad addressing of Amon DataZone, kindly pointed out by Manuel Andre.
Stay away from versions below 1.03.
- New command added, Fast Plot.
- New command added, Test Add.
- New command added, Fast Circle.
I hope you all enjoy using Amon, any bug reports (however small) to my address.
PLEASE NOTE:
============
When upgrading to a newer version of Amon, it is important that you save all your
Amos programs in Ascii format. Sorry I know its slow, but this must be done.
Loading old Amon commands into a newer version will confuse the editor, giving the
wrong commands as new ones may have been added to the list.
--------------------------------------------------------------------------------------
-- COMMAND LIST --
=Rodent X
Function Rodent X has a faster setting than normal Amos.
Works fine with multitasking off.
Example:
VALUE=Rodent X
Also see, "Limit Rodent(x1,y1 to x2,y2)".
__
=Rodent Y
Function Rodent Y has a faster setting than normal Amos.
Works fine with multitasking off
Example:
VALUE=Rodent Y
Also see, "Limit Rodent(x1,y1 to x2,y2)".
__
Limit Rodent x1,y1 to x2,y2
Instruction to Limit Rodent X & Y values to a rectangular area.
Values can be in software or hardware coordinates, depending if you wish to display
a sprite or bob type mouse pointer.
A Lowres screen is default at run time.
Example:
Screen Open 0,640,256,4,Hires
Screen Display 0,128,42,,
Limit Rodent 128,42 to 128+640,42+256
- The above code will lock Rodent X/Y values inside the screen.
__
=Lrodent
This function Checks for a left mouse button. Works fine with multitasking off.
Returns True (-1) or False (0).
Example:
If Lrodent Then Print "Left Mouse"
__
=Rrodent
This function checks for a right mouse button. Works fine with multitasking off.
Returns True (-1) or False (0).
Example:
Do
If Rrodent Then Print "Right mouse"
Loop
__
=Rodent Key
The rodent key function enables you to check whether one or more of the mouse
keys have been pressed. It returns a bit-pattern which holds the current status of the
mouse buttons. It unlike Mouse Key works fine with multitasking off.
This bit-pattern has the following format:
Bit 0 Set to 1 if the LEFT button has been pressed, otherwize zero.
Bit 1 Set to 1 if the RIGHT button has been pressed, otherwize zero.
i.e. Left down=%01 , Right down=%10 , both=$11
= 1 = 2 = 3
Amos/pro supports a 3 button mouse, AMON however does not.
This could be included if you need it?
Exemple.
If Rodent Key=3 Then Print "Both Buttons"
If Lrodent and Rrodent Then Print "Both buttons"
--
Set Rodent X,Y
Use the Set Rodent command to reposition the Rodent x/y coordinates.
The values will still be restricted to that set by the Limit Rodent command.
Example:
Set Rodent 100,100
--
=Keycode
This function acts just like the normal Amos/Pro Scancode command. However this works fine
with multitasking off, and does not require A$=Inkey$ before hand.
Keycode will return 0 with no keyboard inputs.
The return value can be used to test a specific button with "=Key press(Value)".
__
=Key press(Value)
This function checks if a specific key has been pressed. Works fine with multitasking off.
Value is the internal scancode (or keycode) of the key you want to check.
When the key is pressed down, then Key Press will return a value of TRUE (-1).
Otherwise the result will be FALSE (0).
Example:
Do
If Key Press(69) Then Print "Esc pressed"
Loop
__
Video Wait VALUE
The Video Wait instruction helps in accurate screen synchronization, by waiting
until the video beam has reached a given value. If the screens vertical beam is
already greater than VALUE, then there will be no wait. (SPEEDS UP MOST GAMES)
Value needs to be in hardware coordinates.
Say you have a scrolly message at the top of the screen which was 16pixels high, and
the rest of the screen was a still picture.
Then use: Video Wait Y hard(16), with no need to double buffer the screen.
Unlike the (very good) Turbo+ extension instruction "Vbl Wait <Value>".
This does not wait, when the beam has already passed the value.
Video Wait should be used BEFORE a Screen swap, unlike the Amos Wait Vbl which
goes after the Screen swap.
__
Fast Joy0 X,Xstep,Y,Ystep
This instruction adds or subtracts the correct stepping value from the two
variables, depending on the joysticks movement.
This will dramatically speed up & cut down joystick control code.
NOTE: Make sure you point to the variables address, they could be stored
at the start of your code.
i.e. Y=100:ADR_Y=Varptr(Y)
X=100:ADR_X=Varptr(X)
...
...
...
Fast Joy0(ADR_X,1,ADR_Y,1)
Working Example:
X=100
Y=100
Do
Fast Joy0 Varptr(X),1,Varptr(Y),1
Plot X,Y
Wait Vbl
Loop
__
Fast joy1 X,Xstep,Y,Ystep
See Fast Joy0.
__
=Fast Angle(X1,Y1 to X2,Y2,SCALE)
=Fast Angle(X,Y,SCALE) ; uses current rodent coordinates for point A.
The Function returns a frame image for Bob B to face Bob A.
Return Values are from 1 to 576, true angles are not returned but can be
very easily calculated.
X1,Y1 = Bob A
X2,Y2 = Bob B
SCALE is a value used to divide (logical shift) the result.
Range returned
SCALE=0 No scale ........................................ 1 to 576
SCALE=1 Divides Fast Angle result by 2 .................. 1 to 288
SCALE=2 " " " " 4 .................. 1 to 144
SCALE=3 " " " " 8 .................. 1 to 72
SCALE=4 " " " " 16 .................. 1 to 36
SCALE=5 " " " " 32 .................. 1 to 18
SCALE=6 " " " " 64 .................. 1 to 9
NOTE: 2^SCALE will give the divide amount.
i.e. The result can be directly used for a bobs/sprite image:-
RESULT=Fast Angle(BAD_X,BAD_Y to X_COORDS,Y_COORDS,3):Rem Which frame? 1..72
Bob 0,X_coords,Y_coords,RESULT
When using the short version of this function Fast Angle(X,Y,SCALE) which locks onto
the Rodent, make sure you still call Rodent X & Rodent Y to update their values.
The routine may scale down the inputs, effecting the resolution between
the two points. It scales the inputs by half, until they can be directly used
to index internal data. The larger the difference the more they are scaled.
This still gives excellent resolution for games.
A <--------- (x1,y1) A
\ \ |
\ \ |*
\ *\ |**
\ **\ |**
\ ****\ |***
\ *****\|***
B <-- (x2,y2) ***** B **
********
********
******
315° by formula or 504
The above shows correct input order for "B" to face "A".
i.e. if Fast angle result = 504
This can be change into a real angle, by:-
(504/1.6) = 315°; shown in the diagram.
i.e. 576/360°=1.6
Also see Working Example for more detail.
You may ask, why not just return the angle?
- Well, this routine was designed for returning a image number.
- So that the result could be directly used as a bob/sprite image number.
As the routine stands, 576 image turning frames are supported.
I can't see anyone using more than 36 (scale 4) or 72 (Scale 3) turning images.
A bullet firing method you might like to try is:
Use the result from fast angle to direct a accurate bullet firing system,
the total amount of bullet images needed is only half the result or even less.
In the example 144 coordinate firing angles are used, with only 72 image frames.
This gives the bullet a better aim over a longer distance.
To do this just store your x,y stepping offsets in two X/Y Array's, as shown
below.
'-- Store Bullet paths
Dim BULLET_X(144),BULLET_Y(144)
K=37 : N=0 : A=2
Do
BULLET_X(K)=Int Cos Mul(N,32) : BULLET_Y(K)=Int Sin Mul(N,32)
Plot BULLET_X(K)+32,BULLET_Y(K)+32 :Rem test part, should draw circle.
A=5-A : Add N,A
Exit If K=36
Add K,1,1 To 144
Loop
....NOW CUT OUT 36 BOB IMAGES, WHICH ROTATE IN A FULL 360° CIRCLE.
(You may need to rotate a bob in Dpaint to get that)
Then, find the angle you wish to fire to. Directly index both array's with the
returned number, this gives the amount to add on the x & y coordinates of the bullet.
RESULT=Fast Angle(BAD_X,BAD_Y To YOU_X,YOU_Y,2) :Rem 2 = divide result by 4
Add BULLET_X,PX(RESULT)
Add BULLET_Y,PY(RESULT)
Half the result again to give a bullet image frame.
Bob 0,bullet_x,bullet_y,result/2
If your image has less turning frames, then divide down the result.
The above method is rather crude, giving large movements. It would be best to
use the array contents to set up an Amal channel to control firing.
(don't use floating point arithmetic to move objects smoothly across the screen,
it takes far too much CPU time)
---------------------------------------------
Example1: Real number Angle Conversion.
Screen Open 0,320,256,2,Lowres
Double Buffer : Autoback 0
Hide : Limit Rodent 0,0 To 320,256
X2=160 : Y2=128
Do
X1=Rodent X : Y1=Rodent Y
Draw X1,Y1 To X2,Y2
Text X1,Y1,"B"
Text X2,Y2,"A"
A=Fast Angle(X2,Y2,0)
'-- Same as... A=Fast Angle(X1,Y1 To X2,Y2,0)
Text 10,10,"Image="+Str$(A)
Text 10,20,"Angle="+Str$ (A/1.6)+"°"
Screen Swap : Wait Vbl : Cls 0
Loop
---------------------------------------------
Example2: Angle in 10°
ANGLE=Fast Angle(X1,Y1 to X2,Y2,4)*10
---------------------------------------------
Example3: Angle in 5°
ANGLE=Fast Angle(X1,Y1 to X2,Y2,3)*5
---------------------------------------------
Example4: Angle in integers.
ANGLE=Fast Angle(X1,Y1 to X2,Y2,0)*5/8
---------------------------------------------
Example5: Image numbers 1 to 72
ANGLE=Fast Angle(X1,Y1 to X2,Y2,3)
---------------------------------------------
Example6: Image numbers 1 to 576
ANGLE=Fast Angle(X1,Y1 to X2,Y2,0)
---------------------------------------------
__
=Mul Sin(Theta,Multiplier)
A function to return a integer, for Multiplier * sin(theta).
This is a fast fixed point routine, real numbers are not returned.
Amos equivlant:
RESULT=Int(sin(THETA)*MULTIPLIER)
Amon Syntex:
RESULT=Mul Sin(THETA*MULTIPLIER)
Woring Example:
PAL#=50.0
ITERATIONS=20000
Degree :Rem -- Only neded for Amos Cos/Sin
'
Print "TESTING..."
'
Timer=0
For K=0 To ITERATIONS
A=Sin(22)*33
Next K
Print "Amos Sin ";Timer/PAL#;"seconds"
'
Timer=0
For K=0 To ITERATIONS
A=Mul Sin(22,33)
Next K
Print "Amon Integer Mul Cos ";Timer/PAL#;"seconds"
__
=Mul Cos(Theta,Multiplier)
A function to return a integer, for Multiplier * Cos(theta).
This is a fast fixed point routine, real numbers are not returned.
Amos equivlant:
Result=Int(Cos(THETA)*MULTIPLIER)
Amon Syntex:
RESULT=Mul Cos(THETA*MULTIPLIER)
Working Example:
PAL#=50.0
ITERATIONS=20000
Degree :Rem -- Only needed for Amos Cos/Sin
'
Print "TESTING..."
'
Timer=0
For K=0 To ITERATIONS
A=Cos(22)*33
Next K
Print "Amos Cos ";Timer/PAL#;"seconds"
'
Timer=0
For K=0 To ITERATIONS
A=Mul Cos(22,33)
Next K
Print "Amon Integer Mul Cos ";Timer/PAL#;"seconds"
__
Fast Plot X,Y,Colour
This instruction acts just like the normall Amos Plot command, but its much faster.
__
Test Add Test_Array(),Array(),Test,Value,Elemets
This instruction will add Value to Array() if Test_Array()=Test.
Elements is the amount of array elements to take into account.
Example:
Dim TEST_ARRAY(10),ARRAY(10)
...
...
ELEMENTS=11 : TEST=1 : VALUE=100
Test Add Varptr(TEST_ARRAY(0)),VARPTR(ARRAY(0)),TEST,VALUE,ELEMENTS
The same thing in Amos
Dim TEST_ARRAY(10),ARRAY(10)
...
...
ELEMENTS=11 : TEST=1 : VALUE=100
For INDEX=0 to ELEMENTS
IF TEST_ARRAY(INDEX)=TEST
ADD VALUE,ARRAY(INDEX)
END IF
NEXT INDEX
NOTE: Make sure you point to the Array address with Varptr.
__
Fast Circle X,Y,Radius,Colour
This command draws a hollow circle using the radius and centre point X,Y.
Fast circle is many times faster than the Amos circle command, it also does
not give bad results with negative radius values. A radius of zero is
permitted, giving just a single pixel.
At the moment fast circle code is using the fast plot command directly, this means
there is an extra colour check per point plotted and the stack is used.
So this command can still be sped up some more (a lot), when I have some free time.
* End-Of-Doc *